<template>
	<view style="padding-bottom: 120rpx;">
		<u-navbar v-if="!$isWeixin()" :title="title" :title-width="450" :titleBold="true" :background="{ backgroundColor: '#ffffff' }" :is-fixed="true"></u-navbar>

		<u-tabs active-color="#FF7A23" :list="tabList" :current="tabIndex" @change="index => (tabIndex = index)"></u-tabs>

		<view v-if="tabIndex === 0"><relations :list="state.This_Dealer_RelationList"></relations></view>

		<view class="" v-if="tabIndex === 1">
			<u-cell-item title="一级经销商名称" :arrow="false" :value="state.First_Dealer_BaseInfo.Name"></u-cell-item>
			<u-cell-item :border-bottom="false" :arrow="false" title="一级经销商名称" :value="state.Double_Dealer_BaseInfo.Name"></u-cell-item>
			<store-information :data="state.Door_Dealer_BaseInfo"></store-information>
		</view>

		<view class="" v-if="tabIndex === 2">
			<u-cell-group>
				<u-cell-item title="效果图片" :arrow="false" :border-bottom="false" style="padding-bottom: 0;"></u-cell-item>
				<u-cell-item :arrow="false" style="padding: 10rpx;"><image-upload :value="state.EffectList" :readonly="true"></image-upload></u-cell-item>
				<u-cell-item title="实景图片" :arrow="false" :border-bottom="false" style="padding-bottom: 0;"></u-cell-item>
				<u-cell-item :arrow="false" style="padding: 10rpx;"><image-upload :value="state.RealList" :readonly="true"></image-upload></u-cell-item>
				<u-cell-item
					title="金额"
					:arrow="false"
					:border-bottom="false"
					:value="state.StoreRenovationApplyInfo.Price == -1 ? '' : state.StoreRenovationApplyInfo.Price"
				></u-cell-item>
				<u-cell-item
					title="批复金额"
					:arrow="false"
					:border-bottom="false"
					:value="state.StoreRenovationApplyInfo.ReplyPrice == -1 ? '' : state.StoreRenovationApplyInfo.ReplyPrice"
				></u-cell-item>
				<u-cell-item title="审核状态" :arrow="false" :border-bottom="false" :value="state.StoreRenovationApplyInfo.StateName"></u-cell-item>
				<u-cell-item title="初审备注" :arrow="false" :border-bottom="false" :value="state.StoreRenovationApplyInfo.FirstAuditNote"></u-cell-item>
				<u-cell-item title="复审备注" :arrow="false" :border-bottom="false" :value="state.StoreRenovationApplyInfo.ReviewAuditNote"></u-cell-item>
				<u-cell-item title="终审备注" :arrow="false" :border-bottom="false" :value="state.StoreRenovationApplyInfo.FinalAuditNote"></u-cell-item>
			</u-cell-group>
		</view>

		<view class="" v-if="tabIndex === 3">
			<u-cell-item :arrow="false" style="padding: 10rpx;" v-if="state.AgreementPhotoList.filter(item => item.TypeId == 1).length > 0">
				<image-upload :readonly="true" :value="state.AgreementPhotoList.filter(item => item.TypeId == 1)"></image-upload>
			</u-cell-item>
			<u-cell-item :arrow="false" style="padding: 10rpx;" v-if="state.AgreementPhotoList.filter(item => item.TypeId == 4).length > 0">
				<file-picker :readonly="true" :value="state.AgreementPhotoList.filter(item => item.TypeId == 4)"></file-picker>
			</u-cell-item>
		</view>

		<view class="" v-if="tabIndex === 4"><agreement-review :data="state.SR_AgreementInfo"></agreement-review></view>

		<view class="btn-group-fixed"><u-button @tap="backToList">返回列表</u-button></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '动力金协议验收审核详情',
			tabList: [{ name: '销售业务关系' }, { name: '门店信息' }, { name: '专卖店信息' }, { name: '验收协议' }, { name: '验收审核信息' }],
			tabIndex: 0,

			state: {
				ShowLevel: '',
				First_Dealer_BaseInfo: {},
				Double_Dealer_BaseInfo: {},
				Door_Dealer_BaseInfo: {},
				This_Dealer_OtherInfo: {},
				This_Dealer_RelationList: [],
				StoreRenovationApplyInfo: {},
				SR_AgreementInfo: {},
				AgreementPhotoList: [],
				EffectList: [],
				RealList: []
			}
		};
	},
	onLoad(options) {
		if (options.AgreementAcceptanceId) {
			this.AgreementAcceptanceId = options.AgreementAcceptanceId;
		}
		if(options.ApplyType) {
			if(options.ApplyType == 1) {
				this.title = '门店协议验收审核详情'
			}
			if(options.ApplyType == 2) {
				this.title = '动力金协议验收审核详情'
			}
		}

		this.init();

		if (this.$isWeixin()) {
			this.$setTitle(this.title);
		}
	},
	methods: {
		backToList() {
			this.$u.route({
				url: '/pages/review/agreement/index',
				params: {
					SelectType: 2
				}
			});
		},

		init() {
			this.$u.api
				.getStoreDesignReviewDetail({
					AgreementAcceptanceId: this.AgreementAcceptanceId,
					ApplyType: 2
				})
				.then(res => {
					console.log(res);
					const { ResultCode, ResultData } = res;
					if (ResultCode === 1) {
						this.state = ResultData;
						this.state.SR_AgreementInfo.AuditForList = ResultData.AuditForList;
					}
				});
		}
	}
};
</script>

<style></style>
